#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2021/8/2 19:53
# @Author  : 李中华
# @Email   : 1260429766@qq.com
# @File    : ReadExcel.py

from xlrd import open_workbook
from ProjectPath import projectPath
import os

class Excel:
    def get_xls(self):
        cls = []
        xlsxDir = os.listdir(projectPath+'/testcase/casefile/')
        for xlsFile in xlsxDir:
            xlsPath = os.path.join(projectPath,'testcase','casefile',xlsFile)
            if str(xlsFile).split('.')[-1] == 'xlsx':
                openFile = open_workbook(xlsPath)
                # 获取sheet集
                sheetnames = openFile.sheet_names()
                for sheetname in sheetnames:
                    # 获取打开excel的sheet
                    sheet = openFile.sheet_by_name(sheetname)
                    # 获取这个sheet内容行数
                    rows = sheet.nrows
                    for i in range(0,rows):
                        if sheet.row_values(i)[0] != u'用例编号' and sheet.row_values(i)[8] != 'No':
                            cls.append(sheet.row_values(i))
            else:
                pass
        return cls



if __name__ == '__main__':
    print(Excel().get_xls())
